package fun.anin.aninhongbao.controller;

import fun.anin.aninhongbao.dto.WalletDTO;
import fun.anin.aninhongbao.entity.Wallet;
import fun.anin.aninhongbao.result.R;
import fun.anin.aninhongbao.sender.RabbitMQUtil;
import fun.anin.aninhongbao.service.WalletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/***
 *
 * @author anin
 * @date: 2020/3/29 16:07
 * @version : V1.0
 */
@RestController
@RequestMapping("wallet")
public class WalletController {

    @Autowired
    private WalletService walletService;
    @Autowired
    private RabbitMQUtil rabbitMQUtil;
    /**
     * 存钱
     * @return
     */
    @PostMapping("/wallet")
    public R deposit(Wallet wallet){
        return walletService.deposit(wallet);
    }

    /**
     * 存钱
     * @return
     */
    @PostMapping("/test")
    public R test(){
        WalletDTO walletDTO = WalletDTO.builder()
                .userId(2L)
                .toUserId(1L)
                .build();
        rabbitMQUtil.sendLazy("redpacket.BackExchange","redpacket.back",2000,walletDTO);
        return R.ok();
    }
}
